package com.zhj.psi.web.service;

import com.zhj.psi.web.entity.Role;
import com.zhj.psi.web.entity.User;
import com.zhj.psi.web.repository.RoleDao;
import com.zhj.psi.web.repository.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by zhuhuijun on 2017/8/31 17:20
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;
    @Autowired
    private RoleDao roleDao;

    @Override
    public User findByUsername(String username) {
        return userDao.findByUsername(username);
    }

    @Override
    public List<Role> listRoleByUserId(Long userid) {
        return roleDao.findByUserid(userid);
    }

    @Override
    public User findById(long id) {
        return userDao.findOne(id);
    }

    @Override
    public User addUser(User user) {
        return userDao.save(user);
    }
}
